package com.hbk.codemaker;

import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class ClazzPanel extends JPanel{
	
	private final static int CLAZZ_HEIGHT=50;
	
	private JLabel clazzLabel;
	
	private JTextField clazzField;
	
	private JLabel tableLabel;
	
	private JTextField tableField;
	
	private JLabel commentLabel;
	
	private JTextField commentField;
	
	private JLabel aliasLabel;
	
	private JTextField aliasField;
	
	
	public ClazzPanel(int width) {
		clazzLabel=new JLabel("类名");
		tableLabel=new JLabel("表名");
		commentLabel=new JLabel("注释");
		aliasLabel=new JLabel("别名");
		clazzField=new JTextField();
		tableField=new JTextField();
		commentField=new JTextField();
		aliasField=new JTextField();
		
		clazzLabel.setBounds(0, 0, 30, 32);
		clazzField.setBounds(30+10, 0, 150, 32);
		tableLabel.setBounds(30+10+150+10, 0, 30, 32);
		tableField.setBounds(30+10+150+10+30+10, 0, 150, 32);
		
		commentLabel.setBounds(30+10+150+10+30+10+150+10, 0, 30, 32);
		commentField.setBounds(30+10+150+10+30+10+150+10+30+10, 0, 150, 32);
		aliasLabel.setBounds(30+10+150+10+30+10+150+10+30+10+150+10, 0, 30, 32);
		aliasField.setBounds(30+10+150+10+30+10+150+10+30+10+150+10+30+10, 0, 150, 32);
		
		setLayout(null);
		
		add(clazzLabel);
		add(clazzField);
		add(tableLabel);
		add(tableField);
		add(commentLabel);
		add(commentField);
		add(aliasLabel);
		add(aliasField);
		
		setPreferredSize(new Dimension(width, CLAZZ_HEIGHT));
		setBackground(Color.WHITE);
	}
	
	public String getClazz() {
		return clazzField.getText().trim();
	}
	
	public String getTable() {
		return tableField.getText().trim();
	}
	
	public String getComment() {
		return commentField.getText().trim();
	}
	
	public String getAlias() {
		return aliasField.getText().trim();
	}
	
	public void setClazz(String clazz) {
		this.clazzField.setText(clazz);
	}
	
	public void setTable(String table) {
		this.tableField.setText(table);
	}
	
	public void setComment(String comment) {
		this.commentField.setText(comment);
	}
	
	public void setAlias(String alias) {
		this.aliasField.setText(alias);
	}
	
	public void repaint(int width) {
		setPreferredSize(new Dimension(width, CLAZZ_HEIGHT));
		repaint();
	}

}
